package com.kuhyygy.activity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.kuhyygy.R;
import com.kuhyygy.sqlite.dao.SqliteDao;

/**
 * 
 * @author acer
 * 
 */
public class PersonListViewActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.simple_listview);
//		SqliteDao dao = new SqliteDao(this);
//		Cursor cur = dao.getAllPerson();
		ListView lv = (ListView) findViewById(R.id.spListview);
		// SimpleCursorAdapter sca = new SimpleCursorAdapter(
		// PersonListViewActivity.this, R.layout.person, cur,
		// new String[] { "_id", "name", "gender" }, new int[] {
		// R.id.pId, R.id.pName, R.id.pGender });

		String[] from = { "Name", "Gender" };
		int[] to = { R.id.spName, R.id.spGender };
		List<Map<String, ?>> list = new ArrayList<Map<String, ?>>();
		for (int i = 0; i < 10; i++) {
			Map<String, String> m = new HashMap<String, String>();
			m.put("Name", "user" + i);
			m.put("Gender", "男");
			list.add(m);
		}
		SimpleAdapter adapter = new SimpleAdapter(this, list,
				R.layout.simpleadapter_person, from, to);
		lv.setAdapter(adapter);
	}

}
